import 'package:aio/aio.dart';
import 'package:app/src/http/bean/wroks/contract_bean.dart';

///外车运费审核实体类

class CarFreightRates extends ContractCopyInfo {
  //运费明细
  List<FreightDetails>? Freights = null;

  @override
  fromJson(Map<String, dynamic> json) {
    // TODO: implement fromJson
    super.fromJson(json);
    Freights = setGenericFromJson(
        json, 'Freights', <FreightDetails>[], FreightDetails());
  }

  @override
  instance() {
    // TODO: implement instance
    return CarFreightRates();
  }

  @override
  Map<String, dynamic> toJson() {
    // TODO: implement toJson
    // var map = <String, dynamic>{};
    var map = super.toJson();
    map["Freights"] = Freights;
    return map;
  }
}

///运费明细
class FreightDetails extends BaseBean {
  //车牌号
  String? CarCode = "";

  //姓名（驾驶员）
  String? Driver = "";

  //运费总额;Amount8
  String? Amount = "";

  //查看图片
  List<String>? PictureUrls;

  //获取第一张图片
  String? getPictureUrl() {
    if (PictureUrls != null && PictureUrls!.length > 0) {
      return PictureUrls![0];
    }
    return null;
  }

  //详情列表
  List<FreightListDetails>? FreightList = null;

  ///fixme 以下是自己添加的字段。
  bool isOpenAn = false; //是否张开，订单条目

  @override
  fromJson(Map<String, dynamic> json) {
    // TODO: implement fromJson
    Driver = json['Driver']?.toString() ?? "";
    CarCode = json['CarCode']?.toString() ?? "";
    Amount = json['Amount']?.toString() ?? "";
    PictureUrls =
        json["PictureUrls"] != null ? json["PictureUrls"].cast<String>() : [];
    FreightList = setGenericFromJson(
        json, 'FreightList', <FreightListDetails>[], FreightListDetails());
  }

  @override
  instance() {
    // TODO: implement instance
    return FreightDetails();
  }

  @override
  Map<String, dynamic> toJson() {
    // TODO: implement toJson
    var map = <String, dynamic>{};
    map["Driver"] = Driver;
    map["CarCode"] = CarCode;
    map["Amount"] = Amount;
    map["PictureUrls"] = PictureUrls;
    map["FreightList"] = FreightList;
    return map;
  }
}

///运费明细详情列表
class FreightListDetails extends BaseBean {
  //装车号; CarCode2
  String? CarCode = "";

  //发货单号
  String? InvoiceNo = "";

  /// 项目名称
  String? ProjectName = "";

  /// 客户名称
  String? CustomerName = "";

  //总重量
  String? TWeight = "";

  //总平方
  String? TSquare = "";

  //小铁架数
  String? SmallHobNum = "";

  //大铁架数
  String? BigHobNum = "";

  //运费;Amount10
  String? Amount = "";

  @override
  fromJson(Map<String, dynamic> json) {
    // TODO: implement fromJson
    CarCode = json['CarCode']?.toString() ?? "";
    InvoiceNo = json['InvoiceNo']?.toString() ?? "";
    ProjectName = json["ProjectName"]?.toString() ?? "";
    CustomerName = json["CustomerName"]?.toString() ?? "";
    TWeight = json["TWeight"]?.toString() ?? "";
    TSquare = json["TSquare"]?.toString() ?? "";
    SmallHobNum = json["SmallHobNum"]?.toString() ?? "";
    BigHobNum = json["BigHobNum"]?.toString() ?? "";
    Amount = json["Amount"]?.toString() ?? "";
  }

  @override
  instance() {
    // TODO: implement instance
    return FreightListDetails();
  }

  @override
  Map<String, dynamic> toJson() {
    // TODO: implement toJson
    var map = <String, dynamic>{};
    map["CarCode"] = CarCode;
    map["InvoiceNo"] = InvoiceNo;
    map["ProjectName"] = ProjectName;
    map["CustomerName"] = CustomerName;
    map["TWeight"] = TWeight;
    map["TSquare"] = TSquare;
    map["SmallHobNum"] = SmallHobNum;
    map["BigHobNum"] = BigHobNum;
    map["Amount"] = Amount;
    return map;
  }
}
